home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 9 / develop 9 code / Tracks / TracksInfo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-16  |  4.5 KB  |  131 lines  |  [TEXT/MPS ]

  1. #ifndef    __TRACKSINFO__
  2. #define    __TRACKSINFO__
  3.  
  4. //
  5. // some debugging macros...
  6. // To add a trace point, define it in TraceInfo.h and modify the STR# resource in
  7. //    your driver (id 777).
  8. //
  9.  
  10. // Trace stuff
  11.  
  12. #define kInstallTrace    20        // install trace csParam contains ProcPtr and ArgPtr
  13. #define kRemoveTrace    21        // remove trace
  14.  
  15.  
  16. //  On csCode == kInstallTrace, the csParamPtr should be casted to this stucture to
  17. //  fill in your global varibles... 
  18. typedef struct 
  19. {
  20.     ProcPtr    TraceProc;
  21.     Ptr        TraceGlobals;
  22. } TraceData, *TraceDataPtr;
  23.  
  24.  
  25. //
  26. // DIAGNOSTIC ID is a unique number (0-127) that identifies the calling macro.
  27. // Tracing of these functions can be controlled through the cdev.
  28. // If you add to this list or modify it in any way, you also must (should) update the STR#
  29. // In your drivers resource file.  It will be read by the Trace CDEV and Dumptrace.
  30. // 
  31. //    NOTE:  
  32. //    The STR# resource type starts at 1.  Our list starts at 0.  
  33. //    So if you #define kNewTraceCall 87, you need to modify number 88 in the STR# list.
  34. //  
  35. //     The PARTCODE is a number that is associated with the diagnostic id.  They should number from 0 to 
  36. //    however many trace calls you have with the same diag id.  The reason for the partcode is that
  37. //    if the a trace call is locked out, due to an interrupt already accessing the trace code,
  38. //    you will know what happened to the trace info...
  39. //
  40.  
  41. // Level's 1-4 function trace starting points
  42. #define    kTraceLevel1        0
  43. #define    kTraceLevel2        32
  44. #define    kTraceLevel3        64
  45. #define    kTraceLevel4        96
  46.  
  47.  
  48. /** FORMAT ID's for trace calls **/
  49. #define    kTraceStackPeekFmt    1        // StackPeek data- see u:trace:src:drvr:stackpeek for more info
  50. #define    kTraceDataBlockFmt    2        // data1 points to the block. data2 == length of block, 3 ignored.
  51. #define    kTracePStrFmt        3        // data1 = Pstr, 2 & 3 ignored.
  52. #define    kTraceLongFmt        4        // data1 contains four bytes.  2 & 3 ignored.
  53. #define kTracePStrLongFmt    5        // data1 = Pstr, 2 = Long, 3 = 0L;
  54. #define kTraceDataTypeFmt    6        // data1 = Ptr to block, 2 = length, 3 = pstr of Type
  55.  
  56.  
  57.  
  58. #ifdef GOLD
  59.  
  60. #define T_TYPE(diagID, partCode, dataPtr, dataLen, typePStr)  ;
  61. #define T_PSTR(diagID, partCode, thePStr)  ;
  62. #define T_PSTRLONG(diagID, partCode, thePStr, theLong)   ;
  63. #define T_STACK(diagID)     ;
  64. #define TRACE(diagID,partCode,formatID,data1, data2, data3) ;
  65.  
  66. #endif GOLD
  67.  
  68. #ifndef GOLD
  69.  
  70. #define TRACE(diagID,partCode,formatID,data1, data2, data3) \
  71. { register ProcPtr func; \
  72. func = globals->fTraceProcPtr; \
  73. if (func != 0) \
  74. (*((pascal void (*)(Ptr, char, char, char, long, long, long))func)) \
  75.  (globals->fTraceArg, (diagID), (partCode), (formatID), \
  76.  (data1),(data2), (data3)); }
  77.  
  78.  
  79.     
  80. #define T_TYPE(diagID, partCode, dataPtr, dataLen, typePStr) \
  81.     TRACE(diagID, partCode, kTraceDataTypeFmt, (long)dataPtr, dataLen, (long)typePStr)
  82.     
  83. #define T_STACK(diagID) \
  84.     TRACE(diagID, 0, kTraceStackPeekFmt, 0L, 0L, 0L)
  85.  
  86. // For passing a pascal string only...
  87.     
  88. #define T_PSTR(diagID, partCode, thePStr) \
  89.     TRACE(diagID, partCode, kTracePStrFmt, (long)thePStr, 0L, 0L)
  90.  
  91. // For passing a pascal string and a long...  
  92.     
  93. #define T_PSTRLONG(diagID, partCode, thePStr, theLong) \
  94.     TRACE(diagID, partCode, kTracePStrLongFmt, (long)thePStr, (long)theLong, 0L)
  95.  
  96.  
  97. // For passing data blocks...  Pass a pointer to the block and how many bytes to copy.
  98. #define T_DATA(diagID, partCode, theData, theLength) \
  99.     TRACE(diagID, partCode, kTraceDataBlockFmt, (long)theData, (long)theLength, 0L)
  100.  
  101. #endif GOLD
  102.  
  103. /************ CALLING EXAMPLES ***************
  104.  
  105. // Here we are sending two formatted data types... 
  106. // Both have diagnostic ID 97, which means they are both controlled by checkmark 97 (or Str# Id 777, item 98)
  107. // (either on, off, and/or breakpoint set).  If more than one trace call share the same diagID,
  108. // they should have different part codes (in this case, 0 and 1).  They should start at 0 and increment by 1.
  109.  
  110. T_TYPE (97, 0, &myEvent, (long)sizeof(EventRecord), (long)"\pEventRecord");        
  111. T_TYPE(97, 1, dCtl, (long)sizeof(DCtlEntry), (long)"\pDCtlEntry");
  112.  
  113. // Here, in another section of code, we are sending a pascal string.
  114. T_PSTR(48, 0, "\pOh my gosh!");
  115.  
  116. // Here we send a pstring and a long...
  117. T_XXXX(48,0…  ); some Tracks call with diagID 48, partCode 0..
  118. T_PSTRLONG(48, 1, "\paLong = ", aLong);
  119.  
  120. // This sends information about who called current routine
  121. // and what the current routine is.  If c++ is being used, arguments will also be shown.
  122.  
  123. T_STACK(5);    // the 5 is the Diagnostic ID (can be 0-127).
  124.  
  125. // Lastly, this just sends out a block of data... (20 bytes in this example)
  126. T_DATA(45, 0, &dataBlock, 20);
  127.  
  128. *********************************************/
  129.  
  130. #endif __TRACKSINFO__
  131.